﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Slab.Usb;

namespace WrapperDemo
{
    public partial class Form1 : Form
    {
        // This vid and pid is from C8051F320 Demo board's USBHID example
        const int VID = 0x10C4;
        const int PID = 0x82CD;

        HidDevice hid = new HidDevice();

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int n = HidDevice.GeNumDevices(VID, PID);
            this.textBox1.Text = n.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            hid.Open(0, VID, PID);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            MessageBox.Show(hid.IsOpen.ToString());
        }

        private void button4_Click(object sender, EventArgs e)
        {
            hid.Close();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            MessageBox.Show(hid.VendorID);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            MessageBox.Show(hid.ProductID);
        }

        private void button7_Click(object sender, EventArgs e)
        {
            MessageBox.Show(hid.Path);
        }

        private void button8_Click(object sender, EventArgs e)
        {
            MessageBox.Show(hid.Serial);
        }

        private void button9_Click(object sender, EventArgs e)
        {
            MessageBox.Show(hid.InputReportBufferLength.ToString());
        }

        private void button10_Click(object sender, EventArgs e)
        {
            MessageBox.Show(hid.OutputReportBufferLength.ToString());
        }

        private void button11_Click(object sender, EventArgs e)
        {
            MessageBox.Show(hid.FeatureReportBufferLength.ToString());
        }

        private void button12_Click(object sender, EventArgs e)
        {
            MessageBox.Show(hid.MaxReportRequest.ToString());
        }

        private void button13_Click(object sender, EventArgs e)
        {
            hid.FlushBuffers();
        }

        private void button14_Click(object sender, EventArgs e)
        {
            byte[] buffer=new byte[256];
            buffer[0]=0x07; //Report ID
            hid.GetInputReport_Control(buffer,hid.OutputReportBufferLength);

            byte a=buffer[1];
            byte b=buffer[2];
            byte c=buffer[3];
        }

        private void button15_Click(object sender, EventArgs e)
        {

        }
    }
}
